package com.cd2cd.util;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

public final class DataCache {

    public enum CacheEnumKeys {
        TABLE_RELATION,DOMAIN_ANNOTATIONS,VALID_MAP
    }

    private static final Map<String,Map<String,Object>> DATA_CACHE = new HashMap<>();

    private static TreeMap<String,String> TEMPLATE_CACHE = null;

    public static void setTemplateCache(TreeMap<String,String> map) {
        TEMPLATE_CACHE = map;
    }

    public static TreeMap<String,String> getTemplateCache() {
        return TEMPLATE_CACHE;
    }



    public static void setDataCache(CacheEnumKeys key,Map<String, Object> map) {
        DATA_CACHE.put(key.name(),map);
    }

    public static <T> T getDataCache(CacheEnumKeys key,String key2) {
        Map<String, Object> map = DATA_CACHE.get(key.name());

        return map == null ? null : (T)map.get(key2);
    }
}
